package com.hxzrz111.java8.lambda;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Iteration {

    public static void main(String[] args) {

        List<String> features = Arrays.asList("Lambdas", "Default Method", "Stream API", "Date and Time API");

        // Java8 之前
        for (String feature : features) {
            System.out.println(feature);
        }
        System.out.println();

        ArrayList<String> strings = new ArrayList<>();
        // Java8 之后
        features.forEach(n -> {
            if (n == "Lambdas") {
                strings.add(n);
            } else {
                strings.add("xixi");
            }
        });

        // 循环输出遍历结果
        strings.forEach(System.out::println);

    }

}
